using ASP;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
public class Shop_Member_Shop_InvoiceView : Member, IRequiresSessionState
{
	protected ScriptManager ScriptManager1;
	protected TextBox TxtUserName;
	protected TextBox TxtBeginDate;
	protected TextBox TxtEndDate;
	protected Button QuickSearchBtn;
	protected DropDownList DropInvoiceType;
	protected GridView GridView2;
	protected UpdatePanel UpdatePanel4;
	protected DropDownList ddlInvoiceType;
	protected TextBox txtInvoiceNum;
	protected RegularExpressionValidator RegularExpressionValidator1;
	protected TextBox txtInvoiceDrawer;
	protected TextBox txtInputer;
	protected TextBox txtContent;
	protected Button btnConfirm;
	protected HiddenField hfHidenId;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.Query(null, null);
			this.TxtBeginDate.Attributes.Add("onclick", "SelectDate(" + this.TxtBeginDate.UniqueID + ",'yyyy-MM-dd');");
			this.TxtEndDate.Attributes.Add("onclick", "SelectDate(" + this.TxtEndDate.UniqueID + ",'yyyy-MM-dd');");
			this.btnConfirm.Attributes.Add("onClick", "hideDetail()");
		}
	}
	protected void Query(object sender, EventArgs e)
	{
		Shop_InvoiceItem shop_InvoiceItem = new Shop_InvoiceItem(this.conn);
		if (this.TxtBeginDate.Text.Trim().Length < 1)
		{
			this.TxtBeginDate.Text = "2006-01-01";
		}
		if (this.TxtEndDate.Text.Trim().Length < 1)
		{
			this.TxtEndDate.Text = "2500-01-01";
		}
		DataTable invoiceBySalerIDUserNameBegindateEndDate = shop_InvoiceItem.GetInvoiceBySalerIDUserNameBegindateEndDate(base.user.UserID, this.TxtUserName.Text, this.TxtBeginDate.Text, this.TxtEndDate.Text, Convert.ToInt32(this.DropInvoiceType.SelectedValue));
		this.GridView2.DataSource = invoiceBySalerIDUserNameBegindateEndDate;
		this.GridView2.DataBind();
		invoiceBySalerIDUserNameBegindateEndDate.Dispose();
	}
	protected void GridView2_DataBound(object sender, EventArgs e)
	{
		foreach (GridViewRow gridViewRow in this.GridView2.Rows)
		{
			if (gridViewRow.Cells[1].Text != "")
			{
				gridViewRow.Cells[1].Text = DateTime.Parse(gridViewRow.Cells[1].Text).ToShortDateString();
			}
			if (gridViewRow.Cells[9].Text != "")
			{
				gridViewRow.Cells[9].Text = DateTime.Parse(gridViewRow.Cells[9].Text).ToShortDateString();
			}
			if (gridViewRow.Cells[2].Text.Trim() == "0")
			{
				gridViewRow.Cells[2].Text = "地税普通发票";
			}
			if (gridViewRow.Cells[2].Text.Trim() == "1")
			{
				gridViewRow.Cells[2].Text = "国税普通发票";
			}
			if (gridViewRow.Cells[2].Text.Trim() == "2")
			{
				gridViewRow.Cells[2].Text = "增值税发票";
			}
		}
	}
	protected void Button_Edit(object sender, EventArgs e)
	{
		int invoiceID = Convert.ToInt32(this.hfHidenId.Value);
		Shop_InvoiceItem shop_InvoiceItem = new Shop_InvoiceItem(this.conn);
		DataTable invoiceByID = shop_InvoiceItem.GetInvoiceByID(invoiceID);
		if (invoiceByID != null)
		{
			if (invoiceByID.Rows.Count > 0)
			{
				shop_InvoiceItem.UpdateInvoice(this.txtInputer.Text, Convert.ToInt32(this.ddlInvoiceType.SelectedValue), this.txtInvoiceNum.Text, invoiceByID.Rows[0]["Invoicetitle"].ToString(), this.txtContent.Text, this.txtInvoiceDrawer.Text, DateTime.Now, invoiceID);
				this.Query(null, null);
			}
			invoiceByID.Dispose();
		}
	}
}
